# Copyright 2024 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:serving.bzl", "serving_cc_library", "serving_cc_test")

package(default_visibility = ["//visibility:public"])

serving_cc_library(
    name = "phe_2p_dot_product",
    srcs = ["phe_2p_dot_product.cc"],
    hdrs = ["phe_2p_dot_product.h"],
    deps = [
        "//secretflow_serving/core:types",
        "//secretflow_serving/ops:node_def_util",
        "//secretflow_serving/ops:op_factory",
        "//secretflow_serving/ops:op_kernel_factory",
        "//secretflow_serving/util:he_mgm",
        "//secretflow_serving/util:utils",
        "@yacl//yacl/crypto/rand",
    ],
    alwayslink = True,
)

serving_cc_test(
    name = "phe_2p_dot_product_test",
    srcs = ["phe_2p_dot_product_test.cc"],
    deps = [
        ":phe_2p_dot_product",
        "//secretflow_serving/ops/he:test_utils",
        "@yacl//yacl/utils:elapsed_timer",
    ],
)

serving_cc_library(
    name = "phe_2p_decrypt_peer_y",
    srcs = ["phe_2p_decrypt_peer_y.cc"],
    hdrs = ["phe_2p_decrypt_peer_y.h"],
    deps = [
        "//secretflow_serving/ops:node_def_util",
        "//secretflow_serving/ops:op_factory",
        "//secretflow_serving/ops:op_kernel_factory",
        "//secretflow_serving/util:he_mgm",
        "//secretflow_serving/util:utils",
    ],
    alwayslink = True,
)

serving_cc_test(
    name = "phe_2p_decrypt_peer_y_test",
    srcs = ["phe_2p_decrypt_peer_y_test.cc"],
    deps = [
        ":phe_2p_decrypt_peer_y",
        "//secretflow_serving/ops/he:test_utils",
    ],
)

serving_cc_library(
    name = "phe_2p_merge_y",
    srcs = ["phe_2p_merge_y.cc"],
    hdrs = ["phe_2p_merge_y.h"],
    deps = [
        "//secretflow_serving/core:link_func",
        "//secretflow_serving/ops:node_def_util",
        "//secretflow_serving/ops:op_factory",
        "//secretflow_serving/ops:op_kernel_factory",
        "//secretflow_serving/util:he_mgm",
        "//secretflow_serving/util:utils",
    ],
    alwayslink = True,
)

serving_cc_test(
    name = "phe_2p_merge_y_test",
    srcs = ["phe_2p_merge_y_test.cc"],
    deps = [
        ":phe_2p_merge_y",
        "//secretflow_serving/ops/he:test_utils",
        "@yacl//yacl/utils:elapsed_timer",
    ],
)

serving_cc_library(
    name = "phe_2p_reduce",
    srcs = ["phe_2p_reduce.cc"],
    hdrs = ["phe_2p_reduce.h"],
    deps = [
        "//secretflow_serving/ops:node_def_util",
        "//secretflow_serving/ops:op_factory",
        "//secretflow_serving/ops:op_kernel_factory",
    ],
    alwayslink = True,
)

serving_cc_test(
    name = "phe_2p_reduce_test",
    srcs = ["phe_2p_reduce_test.cc"],
    deps = [
        ":phe_2p_reduce",
        "//secretflow_serving/ops/he:test_utils",
    ],
)
